<?php

error_reporting(E_ALL);

/**
 * clase contenedora de los metodos que permiten el manejo de datos dentro del
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/**
 * clase encargada de la conexion con la base de datos MYSQL
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.Conexion.php');

/* user defined includes */
// section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088A-includes begin
// section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088A-includes end

/* user defined constants */
// section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088A-constants begin
// section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088A-constants end

/**
 * clase contenedora de los metodos que permiten el manejo de datos dentro del
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class Modelo
    extends Conexion
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    // --- OPERATIONS ---

    /**
     * metodo que permite obtener todas las hileras de una consulta de datos
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function getAllRows()
    {
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088B begin
		$sql = "SELECT * FROM camiones";
		return $this->execQuery($sql);
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088B end
    }

    /**
     * metodo que permite buscar un registro de datos por identificador
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function searchById($id)
    {
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088D begin
		$sql = "select * from camiones where Id = '".@$id[Id]."'";
		$row0 = $this->execQuery($sql);
		return $row0[0];
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088D end
    }

    /**
     * metodo que permite dar de alta un registro de datos(insert)
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  data
     * @return mixed
     */
    public function insert($data)
    {
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:0000000000000890 begin
		
		$marca = @$data['marca'];
		$modelo = @$data['modelo'];
		$color = @$data['color'];
		$tipo = @$data['tipo'];
		$capacidad = @$data['capacidad'];
		$precio = @$data['precio'];
		
		
		$sql = "insert into camiones (marca,modelo,color,tipo,capacidad,precio) values ('$marca','$modelo','$color', '$tipo','$capacidad','$precio')";
		
		$this->execQuery($sql);
		return mysql_insert_id();
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:0000000000000890 end
    }

    /**
     * metodo que permite modificar un registro de datos existente(update)
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  data
     * @return mixed
     */
    public function update($data)
    {
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:0000000000000893 begin
		$sql = " update camiones set
		marca = '".@$data[marca]."',
		modelo = '".@$data[modelo]."',
		color = '".@$data[color]."',
		tipo = '".@$data[tipo]."',
		capacidad = '".@$data[capacidad]."',
		precio = '".@$data[precio]."'
		where Id = '".@$data[Id]."'
		";
		
		$this->execQuery($sql);
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:0000000000000893 end
    }

    /**
     * metodo que permite borrar un registro de dato existente(delete)
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function delete($id)
    {
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:0000000000000896 begin
		$sql= "delete from camiones where Id = '".@$id[Id]."'";
		$this->execQuery($sql);
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:0000000000000896 end
    }

} /* end of class Modelo */

?>